<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="share-button">Share</button>
</body>
<script>
    const shareButton = document.getElementById("share-button");

    if (navigator.share) {
        shareButton.addEventListener("click", async () => {
            try {
                await navigator.share({
                    title: document.title, // Title of the page
                    url: window.location.href // URL of the current page
                });
                console.log("Page shared successfully");
            } catch (err) {
                console.error("Error sharing:", err);
            }
        });
    } else {
        // Fallback for browsers that don't support the Web Share API
        shareButton.style.display = "none"; // Hide the button or provide an alternative
    }
</script>
</html>
